//
//  PhotoScan.m
//  sxyq
//
//  Created by yang yang on 2020/7/17.
//

#import <Foundation/Foundation.h>
#import "PhotoScan.h"
#import <Photos/Photos.h>

@implementation PhotoScan

-(BOOL)isPhotoUsageDescriptionSet
{
  NSDictionary * plist = [[NSBundle mainBundle] infoDictionary];
  if ([plist objectForKey:@"NSPhotoLibraryUsageDescription" ] == NO &&
      [[NSBundle mainBundle] localizedStringForKey: @"NSPhotoLibraryUsageDescription" value: nil table: @"InfoPlist"] == NO) {
    return NO;
  }
  if ([plist objectForKey:@"NSPhotoLibraryAddUsageDescription" ] == NO &&
      [[NSBundle mainBundle] localizedStringForKey: @"NSPhotoLibraryAddUsageDescription" value: nil table: @"InfoPlist"] == NO) {
    return NO;
  }
    
  return YES;
}

-(BOOL)checkPermission
{
    PHAuthorizationStatus author = [PHPhotoLibrary authorizationStatus];
    if (author == PHAuthorizationStatusRestricted || author == PHAuthorizationStatusDenied){
    //无权限
        return NO;
    }
    return YES;
}

@end
